let arr = [2, 1, 7, 4, 3, 1, 6, 5]

function quick_sort(arr) {
  
  if (arr.length <= 1) return arr
  let mid = arr.length >> 1
  let middle = arr.splice(mid, 1)[0]//将mid放入middle数组中
  let l = []
  let r = []
  const len = arr.length// 计算mid被扣除之后的长度
  for (let i = 0; i < len; i++) {
    if (arr[i] < middle) l.push(arr[i])
    else r.push(arr[i])  
  }
  // quick_sort(l)
  // quick_sort(r)
  return [...quick_sort(l), middle, ...quick_sort(r)]
}
console.log(quick_sort(arr));
